#include "ResultTable.h"
#include <iostream>

ResultTable::ResultTable(void) {
}


ResultTable::~ResultTable(void) {
}

bool ResultTable::replaceSynonym(std::string s1, std::string s2) {
	//std::cout << s1 << " " << s2 <<std::endl;
	for (int i = 0; i< mSynonymVector.size(); i++) {
		if (mSynonymVector.at(i).compare(s2) == 0) {
			mSynonymVector.at(i) = s1;
		}
	}
	return true;
}

ConstraintAttrType ResultTable::getAttributeAtIndex(int index) {
	// Error checking
	if (index < 0 || index >= getNumberOfEntries()) {
		return CONSTRAINT_ATTR_INVALID;
	}
	return mAttributeVector.at(index);
}

bool ResultTable::addSynonym(std::string synonym, ConstraintAttrType type) {
	// Error checking
	if (synonym == "" || type == CONSTRAINT_ATTR_INVALID) {
		return false;
	}

	// Insert the synonym into the table
	// Insert the attribute requirement into the table
	mSynonymVector.push_back(synonym);
	mAttributeVector.push_back(type);
	return true;
}

bool ResultTable::addSynonym(std::string synonym) {
	// Error checking
	if (synonym == "") {
		return false;
	}

	// Insert the synonym into the table
	// Insert the NONE requirement into the table
	mSynonymVector.push_back(synonym);
	mAttributeVector.push_back(NONE);
	return true;
}

std::string ResultTable::getSynonymAtIndex(int index) {
	// Error checking
	if (index < 0 || index >= getNumberOfEntries()) {
		return "";
	}
	
	return mSynonymVector.at(index);
}

int ResultTable::getNumberOfEntries() {
	return mSynonymVector.size();
}